package com.qiangqiang.repository;

import com.qiangqiang.entity.DorStu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * Created by q on 2018/2/1.
 */
public interface DorStuReposity extends JpaRepository<DorStu, String> {
    //增加一个记录

    /**
     * 删除一个记录
     *
     * @param dId
     * @param sId
     */

    void deleteByDIdAndSId(String dId, String sId);

    /**
     * 查询一个记录
     * @param dId
     * @param sId
     * @return
     */
    DorStu queryByDIdAndSId(String dId,String sId);

    DorStu queryBySId(String sId);

    //学生更换宿舍

    /**
     * 根据学号查询宿舍
     * @param sId
     * @return
     */
    @Query(value = "select d_id from dor_stu where s_id=:sId",nativeQuery = true)
    String queryDIdBySId(@Param("sId") String sId);
}
